home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 66
/
Vol 66.iso
/
games
/
bob_espo.swf
/
scripts
/
__Packages
/
MovingObject.as
< prev
next >
Wrap
Text File
|
2013-04-24
|
6KB
|
227 lines
class MovingObject extends State
{
static var sSTATE_IDLE_UP = "IdleUp";
static var sSTATE_IDLE_DOWN = "IdleDown";
static var sSTATE_IDLE_LEFT = "IdleLeft";
static var sSTATE_IDLE_RIGHT = "IdleRight";
static var sSTATE_LEFT = "Left";
static var sSTATE_RIGHT = "Right";
static var sSTATE_UP = "Up";
static var sSTATE_DOWN = "Down";
static var nMAX_MOVEMENT = 20;
function MovingObject(_mcRef)
{
super(_mcRef);
this.setState(MovingObject.sSTATE_RIGHT);
this.nCurrentDir = CTRLGame.nDIR_RIGHT;
this.nMovement = 0;
}
function get FuturePos()
{
var _loc2_ = new Object();
_loc2_.x = 0;
_loc2_.y = 0;
switch(this.sState)
{
case MovingObject.sSTATE_UP:
_loc2_.x = this.mcRef._x;
_loc2_.y = this.mcRef._y - this.nMovement;
break;
case MovingObject.sSTATE_DOWN:
_loc2_.x = this.mcRef._x;
_loc2_.y = this.mcRef._y + this.nMovement;
break;
case MovingObject.sSTATE_LEFT:
_loc2_.x = this.mcRef._x - this.nMovement;
_loc2_.y = this.mcRef._y;
break;
case MovingObject.sSTATE_RIGHT:
_loc2_.x = this.mcRef._x + this.nMovement;
_loc2_.y = this.mcRef._y;
break;
default:
_loc2_.x = this.mcRef._x;
_loc2_.y = this.mcRef._y;
}
return _loc2_;
}
function getMiCasePos()
{
var _loc2_ = 0.5 * MovingObject.nMAX_MOVEMENT;
var _loc3_ = new Object();
_loc3_.x = 0;
_loc3_.y = 0;
switch(this.sState)
{
case MovingObject.sSTATE_UP:
_loc3_.x = this.mcRef._x;
_loc3_.y = this.mcRef._y - _loc2_;
break;
case MovingObject.sSTATE_DOWN:
_loc3_.x = this.mcRef._x;
_loc3_.y = this.mcRef._y + _loc2_;
break;
case MovingObject.sSTATE_LEFT:
_loc3_.x = this.mcRef._x - _loc2_;
_loc3_.y = this.mcRef._y;
break;
case MovingObject.sSTATE_RIGHT:
_loc3_.x = this.mcRef._x + _loc2_;
_loc3_.y = this.mcRef._y;
break;
default:
_loc3_.x = this.mcRef._x;
_loc3_.y = this.mcRef._y;
}
return _loc3_;
}
function get Moving()
{
return this.nMovement != 0;
}
function getWishPos(_nDir)
{
var _loc3_ = new Object();
_loc3_.x = 0;
_loc3_.y = 0;
switch(_nDir)
{
case CTRLGame.nDIR_UP:
_loc3_.x = this.mcRef._x;
_loc3_.y = this.mcRef._y - MovingObject.nMAX_MOVEMENT;
break;
case CTRLGame.nDIR_DOWN:
_loc3_.x = this.mcRef._x;
_loc3_.y = this.mcRef._y + MovingObject.nMAX_MOVEMENT;
break;
case CTRLGame.nDIR_LEFT:
_loc3_.x = this.mcRef._x - MovingObject.nMAX_MOVEMENT;
_loc3_.y = this.mcRef._y;
break;
case CTRLGame.nDIR_RIGHT:
_loc3_.x = this.mcRef._x + MovingObject.nMAX_MOVEMENT;
_loc3_.y = this.mcRef._y;
break;
default:
_loc3_.x = this.mcRef._x;
_loc3_.y = this.mcRef._y;
}
return _loc3_;
}
function getWishMidPos(_nDir)
{
var _loc3_ = new Object();
_loc3_.x = 0;
_loc3_.y = 0;
switch(_nDir)
{
case CTRLGame.nDIR_UP:
_loc3_.x = this.mcRef._x;
_loc3_.y = this.mcRef._y - 0.5 * MovingObject.nMAX_MOVEMENT;
break;
case CTRLGame.nDIR_DOWN:
_loc3_.x = this.mcRef._x;
_loc3_.y = this.mcRef._y + 0.5 * MovingObject.nMAX_MOVEMENT;
break;
case CTRLGame.nDIR_LEFT:
_loc3_.x = this.mcRef._x - 0.5 * MovingObject.nMAX_MOVEMENT;
_loc3_.y = this.mcRef._y;
break;
case CTRLGame.nDIR_RIGHT:
_loc3_.x = this.mcRef._x + 0.5 * MovingObject.nMAX_MOVEMENT;
_loc3_.y = this.mcRef._y;
break;
default:
_loc3_.x = this.mcRef._x;
_loc3_.y = this.mcRef._y;
}
return _loc3_;
}
function canMove()
{
var _loc2_ = false;
if(!Controller.getRef().isPaused() && !CTRLGame.getRef().Screen.isInMiniGame())
{
_loc2_ = true;
}
return _loc2_;
}
function inverseDirection(_nCurrentDir)
{
switch(_nCurrentDir)
{
case CTRLGame.nDIR_UP:
var _loc3_ = CTRLGame.nDIR_DOWN;
break;
case CTRLGame.nDIR_DOWN:
_loc3_ = CTRLGame.nDIR_UP;
break;
case CTRLGame.nDIR_LEFT:
_loc3_ = CTRLGame.nDIR_RIGHT;
break;
case CTRLGame.nDIR_RIGHT:
_loc3_ = CTRLGame.nDIR_LEFT;
}
return _loc3_;
}
function isTrackOkay(_nFutureDir)
{
var _loc3_ = false;
var _loc4_ = this.getWishPos(_nFutureDir);
var _loc5_ = CTRLGame.getRef().Maze.getVTracks(_loc4_.x,_loc4_.y);
var _loc6_ = CTRLGame.getRef().Maze.getHTracks(_loc4_.x,_loc4_.y);
switch(_nFutureDir)
{
case CTRLGame.nDIR_UP:
case CTRLGame.nDIR_DOWN:
for(var i in _loc5_)
{
if(_loc5_[i].hitTest(_loc4_.x,_loc4_.y,true))
{
_loc3_ = true;
break;
}
}
break;
case CTRLGame.nDIR_LEFT:
case CTRLGame.nDIR_RIGHT:
for(var i in _loc6_)
{
if(_loc6_[i].hitTest(_loc4_.x,_loc4_.y,true))
{
_loc3_ = true;
break;
}
}
}
return _loc3_;
}
function manageMovement()
{
}
function IdleUp()
{
}
function IdleDown()
{
}
function IdleLeft()
{
}
function IdleRight()
{
}
function Left()
{
}
function Up()
{
}
function Right()
{
}
function Down()
{
}
}